#include "PlayProducer.h"


PlayProducer::PlayProducer(void)
{
	_isPlay = false;
	_startTime = 0;
	_curPlayIndex = 0;
}


PlayProducer::~PlayProducer(void)
{
}

void PlayProducer::detectEvent()
{
	int i = 0;
	if(_isPlay){
		for(i = _curPlayIndex; i < _wholeNotation.size(); i++){
			if((clock()-_startTime) > _wholeNotation[i].first)
				__curEventDetected = _wholeNotation[i].second;
			else
				break;
		}
	}
	_curPlayIndex = i;
}

void PlayProducer::startPlay(MusicNotation musicNotation)
{
	_isPlay = true;
	_wholeNotation = musicNotation.getWholeNotation();
	_startTime = clock();
}

void PlayProducer::stopPlay()
{
	_isPlay = false;
}
